import UIKit

/**
    B站：https://www.bilibili.com/video/BV144411C7Gg?p=37

    第37课 协议 protocol
 */

class TestClass {}

protocol Protocol1 {
    // 可读/可写
    var value1: String{set get}
    
    func play1() -> String
}

protocol Protocol2 {
    // 只读
    var value2: String{get}
    
    func play2() -> String
}

// 继承了 1个类(TestClass)， 2个接口(Protocol1, Protocol2)
class Data: TestClass, Protocol1, Protocol2 {
    var value1: String
    var value2: String {
        return "value2"
    }
    let value3: String = "abc"
    
    func play1() -> String {
        return value1
    }
    
    func play2() -> String {
        return value2
    }
    
    init(value1: String) {
        self.value1 = value1
    }
    
}

let demo = Data(value1: "hello world v1")
print("demo value1=\(demo.value1), value2=\(demo.value2)\n")


demo.value1 = "111"
print("value1=", demo.play1())

// Cannot assign to property: 'value2' is a get-only property
//demo.value2 = "2222" // value2 是只读属性
print("value2=", demo.play2())
